<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%vote_log}}".
 *
 * @property integer $id
 * @property integer $vid
 * @property integer $uid
 * @property string $openid
 * @property string $nickname
 * @property string $ip
 * @property integer $num
 * @property integer $created_at
 */
class VoteLog extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%vote_log}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['vid', 'openid', 'nickname', 'num'], 'required'],
            ['uid', 'default', 'value' => 60002],
            ['ip', 'default', 'value' => Yii::$app->request->headers->get('x-real-ip')],
            [['uid', 'cid', 'num', 'created_at'], 'integer'],
            ['vid', 'string', 'max' => 200],
            ['openid', 'string', 'max' => 32],
            ['nickname', 'string', 'max' => 20],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            '活动ID' => '选手ID',
            'vid' => '选手ID',
            'uid' => '公众号ID',
            'openid' => 'Openid',
            'nickname' => '昵称',
            'ip' => 'Ip',
            'num' => '票数',
            'created_at' => '投票时间',
        ];
    }
}
